package com.net.xpay.partner.controller.partner;

import com.net.common.model.ResultPagedList;
import com.net.xpay.common.domain.partner.Partner;
import com.net.xpay.common.manager.partner.PartnerSettleLogManager;
import com.net.xpay.common.model.PartnerUnionSettleLogResultModel;
import com.net.xpay.common.model.search.PartnerUnionSettleLogSearchModel;
import com.net.xpay.core.utils.BeanCopierUtil;
import com.net.xpay.partner.secutiry.RequestUser;
import com.net.xpay.partner.vo.PartnerUnionSettleLogVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RestController
@RequestMapping("/partner/partner-union-settle-log")
@Api(tags = "合伙人/合伙人结算记录",description = "合伙人结算记录")
public class PartnerUnionSettleLogController {

    @Autowired
    private PartnerSettleLogManager partnerSettleLogManager;

    @ApiOperation(value = "合伙人结算记录")
    @PostMapping(value = "/search")
    public ResultPagedList<PartnerUnionSettleLogVo> search(@ApiIgnore @RequestUser Partner partner, @RequestBody PartnerUnionSettleLogSearchModel searchModel){
        searchModel.setPartnerId(partner.getId());
        // 根据查询条件进行查询
        List<PartnerUnionSettleLogResultModel> records = partnerSettleLogManager.searchUnion(searchModel);
        // 查询带条件后数据的条数
        long count = partnerSettleLogManager.searchUnionCount(searchModel);

        List<PartnerUnionSettleLogVo> vos = BeanCopierUtil.batchCopy(PartnerUnionSettleLogResultModel.class,PartnerUnionSettleLogVo.class, records);

        return new ResultPagedList<>(vos,count,searchModel);
    }


}
